<% layout('/layouts/default.html', {title: '数据管理', libs:
['validate','fileupload','ueditor','dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text(ztOrder.isNewRecord ? '新增订单' :
				'查看订单【租】')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool"
					data-widget="collapse">
					<i class="fa fa-minus"></i>
				</button>
			</div>
		</div>

		<#form:form id="inputForm" model="${ztOrder}"
		action="${ctx}/ztOrder/save" method="post" class="form-horizontal">
		<div class="box-body">
			<div class="form-unit">${text('订单信息')}</div>
			<#form:hidden path="id"/>
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('物流名称')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
						<#form:select path="logisticsCode"
							items="${logisticsList}" itemLabel="logisticName" itemValue="logisticsCode"
							blankOption="true" class="form-control required"/>
						</div>

					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required hide">*</span> ${text('物流单号')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-5">
							<#form:input path="logistics"
							maxlength="200" class="form-control required "/>
						<input id="retrieval" onclick="openWin('${ctx}/ztWl/list?logistics=${ztGoodsOrder.logistics}&logisticsCode=${ztGoodsOrder.logisticsCode}', 900, 600)"
				class="btn btn-primary" type="button" style="background:#00B2EE" value="查看物流信息" />
						</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('订单号')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztOrder.order}</div>
					</div>
				</div>

				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required hide">*</span> ${text('小程序用户名')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztOrder.ztAdmin.name}</div>
					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('收货人')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztOrder.name}</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required hide">*</span> ${text('电话号码')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztOrder.phone}</div>
					</div>
				</div>
			</div>


			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('原价')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztOrder.origPrice}</div>

					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required hide">*</span> ${text('实际总价')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztOrder.totalPrice}</div>
					</div>
				</div>

			</div>

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required hide">*</span> ${text('下单时间')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							${ztOrder.orderTime,dateFormat="yyyy-MM-dd HH:mm:ss"}</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required hide">*</span> ${text('付款时间')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">
							${ztOrder.payTime,dateFormat="yyyy-MM-dd HH:mm:ss"}</div>
					</div>
				</div>
			</div>

			

			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('订单状态')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztOrder.orderstatus}</div>

					</div>
				</div>
				
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('优惠')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztOrder.quanselfid}</div>

					</div>
				</div>

			</div>
			
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('押金')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztOrder.deposit}</div>

					</div>
				</div>
				
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('租金')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztOrder.origPrice-ztOrder.deposit}</div>

					</div>
				</div>

			</div>
			
			<div class="row">
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('押期')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztOrder.count}月</div>

					</div>
				</div>
				
				<div class="col-xs-6">
					<div class="form-group">
						<label class="control-label col-sm-4" title=""> <span
							class="required">*</span> ${text('剩余时间')}：<i
							class="fa icon-question hide"></i></label>
						<div class="col-sm-8">${ztOrder.sysj}</div>

					</div>
				</div>

			</div>
			
			
			
			<% if(ztOrder.ztQuanselfList.~size>0){ %>
				<h4 class="form-unit">${text('卡券列表')}</h4>
			<div class="ml10 mr10">
				<table id="quanDataGrid"></table>
			</div>
			<%}%>


			<h4 class="form-unit">${text('购买商品列表')}</h4>
			<div class="ml10 mr10">
				<table id="testDataChildDataGrid"></table>
			</div>



		</div>
		<div class="box-footer">
			<div class="row">
				<div class="col-sm-offset-2 col-sm-10">

					<button type="button" class="btn btn-sm btn-default" id="btnCancel"
						onclick="js.closeCurrentTabPage()">
						<i class="fa fa-reply-all"></i> ${text('关 闭')}
					</button>
				</div>
			</div>
		</div>
		</#form:form>
	</div>
</div>
<% } %>

<script>
//初始化测试数据子表DataGrid对象
$("#testDataChildDataGrid").dataGrid({

	data: ${toJson(ztOrder.ztGoodsList)},
	datatype: "local", // 设置本地数据
	autoGridHeight: function(){return 'auto'}, // 设置自动高度
	
	// 设置数据表格列
	columnModel: [
{header:'${text('商品名')}', name:'title', width:200, align:"center", sortable:false, fixed:true, formatter: function(val, obj, row, act){
	var actions = [];
	actions.push('<a href="${ctx}/ztGoods/queForm?id='+row.id+'&color='+row.code+'" class="btnList" title="'+val+'" >'+val+'</a>');
	return actions.join('');
}, editoptions: {defaultValue: 'new'}},
		{header:'颜色', name:'code', width:100,align:"center"},
		{header:'数量', name:'count', width:100,align:"center"},
		{header:'单价', name:'price',align:"center", width:100},
		{header:'总价', name:'goodstemp',align:"center", width:100}
		
	],
	// 编辑表格参数
	editGrid: false,				// 是否是编辑表格
	
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});

//初始化测试数据子表DataGrid对象
$("#quanDataGrid").dataGrid({

	data: ${toJson(ztOrder.ztQuanselfList)},
	datatype: "local", // 设置本地数据
	autoGridHeight: function(){return 'auto'}, // 设置自动高度
	
	// 设置数据表格列
	columnModel: [

		{header:'卡券名', name:'name', width:150,align:"center"},
		{header:'${text('图片')}', name:'imgs',  width:150, align:"center",formatter: function(val, obj, row, act){
			return '<img style="width:40px;height:40px;" src="'+val+'"></img>';
		}},
		{header:'卡券面值', name:'price',align:"center", width:100},
		{header:'${text('状态')}', name:'type', width:100, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('zt_quan_type')}, val, '${text('现金券')}', true);
		}}
		
	],
	
	// 编辑表格参数
	editGrid: false,				// 是否是编辑表格
	
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>

<script>

function openWin(u, w, h) { 
    var l = (screen.width - w) / 2; 
    var t = (screen.height - h) / 2; 
    var s = 'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l; 
    s += ', toolbar=no, scrollbars=no, menubar=no, location=no, resizable=no'; 
    open(u, 'oWin', s); 
} 
	$("#inputForm").validate({
		submitHandler : function(form) {
			js.ajaxSubmitForm($(form), function(data) {
				js.showMessage(data.message);
				if (data.result == Global.TRUE) {
					js.closeCurrentTabPage(function(contentWindow) {
						contentWindow.page();
					});
				}
			}, "json");
		}
	});
</script>